package com.bytebufferex;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;

public class Tester {
	
	
	public static void main(String[] args) {
		
		ByteBuf buf = Unpooled.buffer(16);
		
		
		
		for (int i = 0; i < buf.capacity(); i++) {
			
			buf.writeByte(i+1);
			System.out.println("writerIndex="+buf.writerIndex());
		}
		
		
		String hexString=ByteBufUtil.hexDump(buf);
		System.out.println("Hex="+hexString);
		//buf.clear();
		
	    while(buf.isReadable()){
	    	System.out.println(buf.readByte());
	    	System.out.println("readerIndex="+buf.readerIndex());
	    }
	    
	    System.out.println("=============================================");
		System.out.println(buf.refCnt());
		ReferenceCountUtil.release(buf);
		System.out.println(buf.refCnt());
		System.out.println(buf.writerIndex());
	
		

		
	}

}
